package com.sunmouse.toolkit;

import android.app.Activity;
import android.app.Application;

import com.sunmouse.toollib.utils.ThreadPoolUtils;

import java.util.ArrayList;

/**
 * Created by Kvin on 2017/5/26.
 */
public class BaseApp extends Application {
    private static BaseApp mApp;
    private ArrayList<Activity> acts;

    @Override
    public void onCreate() {
        super.onCreate();
        ThreadPoolUtils.init(8);
        acts=new ArrayList<>();
        mApp = this;

    }




    /**
     * single instance
     */
    public static BaseApp getInstance() {
        return mApp;
    }


    /**
     * add activity
     */
    public void addAct(Activity act) {
        if (act != null) {
            acts.add(act);
        }
    }

    /**
     * exit  system
     */
    public void exit() {
        for (Activity act : acts) {
            if (act != null) act.finish();
        }
    }


}
